package com.imageim.yimirror.ui.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.imageim.yimirror.R;
import com.imageim.yimirror.common.ui.GlideUtils;

import java.util.List;

/**
 * Created by Yuaihen.
 * on 2018/8/7
 */
public class ColorReportAdapter extends RecyclerView.Adapter<ColorReportAdapter.ColorReportHolder> {

    private Context mContext;
    private List<String> mData;

    public ColorReportAdapter(Context context, List<String> list) {
        mContext = context;
        mData = list;
    }

    public void updateColorPhoto(List<String> list) {
        mData = list;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ColorReportHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_color_report, parent, false);
        return new ColorReportHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ColorReportHolder holder, int position) {
        GlideUtils.display(holder.ivPhoto, mData.get(position));
    }


    @Override
    public int getItemCount() {
        return mData == null ? 0 : mData.size();
    }

    static class ColorReportHolder extends RecyclerView.ViewHolder {
        private ImageView ivPhoto;

        public ColorReportHolder(View itemView) {
            super(itemView);
            ivPhoto = itemView.findViewById(R.id.iv_photo);
        }
    }
}
